package com.ruoyi.job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.business.waterManagement.WrStatvolH;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.job.mapper.WrStatvolHMapper;
import com.ruoyi.job.service.IWrStatvolHService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 测站时段水量Service业务层处理
 * 
 * @author hwd
 * @date 2023-02-21
 */
@Service
public class WrStatvolHServiceImpl extends ServiceImpl<WrStatvolHMapper, WrStatvolH> implements IWrStatvolHService {

    @Autowired
    private WrStatvolHMapper wrStatvolHMapper;

    /**
     * 查询测站时段水量
     * 
     * @param statCd 测站时段水量主键
     * @return 测站时段水量
     */
    @Override
    public WrStatvolH selectWrStatvolHByStatCd(String statCd)
    {
        return wrStatvolHMapper.selectWrStatvolHByStatCd(statCd);
    }

    /**
     * 查询测站时段水量列表
     * 
     * @param wrStatvolH 测站时段水量
     * @return 测站时段水量
     */
    @Override
    public List<WrStatvolH> selectWrStatvolHList(WrStatvolH wrStatvolH)
    {
        if (wrStatvolH.getStatHour()!=null){
            String [] strings= DateUtils.jsYmd(wrStatvolH.getStatHour());
            String yy =strings[0];
            String mm =strings[1];
            String dd =strings[2];
            wrStatvolH.setYy(yy);
            wrStatvolH.setMm(mm);
            wrStatvolH.setDd(dd);
        }
        return wrStatvolHMapper.selectWrStatvolHList(wrStatvolH);
    }

    /**
     * 新增测站时段水量
     * 
     * @param wrStatvolH 测站时段水量
     * @return 结果
     */
    @Override
    public int insertWrStatvolH(WrStatvolH wrStatvolH)
    {
        return wrStatvolHMapper.insertWrStatvolH(wrStatvolH);
    }

    /**
     * 修改测站时段水量
     * 
     * @param wrStatvolH 测站时段水量
     * @return 结果
     */
    @Override
    public int updateWrStatvolH(WrStatvolH wrStatvolH)
    {
        return wrStatvolHMapper.updateWrStatvolH(wrStatvolH);
    }

    /**
     * 批量删除测站时段水量
     * 
     * @param statCds 需要删除的测站时段水量主键
     * @return 结果
     */
    @Override
    public int deleteWrStatvolHByStatCds(String[] statCds)
    {
        return wrStatvolHMapper.deleteWrStatvolHByStatCds(statCds);
    }

    /**
     * 删除测站时段水量信息
     * 
     * @param statCd 测站时段水量主键
     * @return 结果
     */
    @Override
    public int deleteWrStatvolHByStatCd(String statCd)
    {
        return wrStatvolHMapper.deleteWrStatvolHByStatCd(statCd);
    }

    @Override
    public WrStatvolH countDayByWrStatvolH(WrStatvolH wrStatvolH) {
        String [] strings= DateUtils.jsYmd(wrStatvolH.getStatHour());
        String yy =strings[0];
        String mm =strings[1];
        String dd =strings[2];
        wrStatvolH.setYy(yy);
        wrStatvolH.setMm(mm);
        wrStatvolH.setDd(dd);
        return wrStatvolHMapper.countDayByWrStatvolH(wrStatvolH);
    }

    @Override
    public void insertOrUpdateWrStatvolH(WrStatvolH wrStatvolH) {
        wrStatvolHMapper.insertOrUpdateWrStatvolH(wrStatvolH);
    }


}
